import 'package:flutter/material.dart';

class Widget_showBottomSheet_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_showBottomSheet_State();
  }
}

class Widget_showBottomSheet_State extends State<Widget_showBottomSheet_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("showBottomSheet"),
          ),
          floatingActionButton: Builder(builder: (BuildContext context) {
            return FloatingActionButton(
              onPressed: () =>
                  Scaffold
                      .of(context)
                      .showBottomSheet<Null>(
                          (BuildContext context) {
                        return Container(
                          height: 300.0,
                          color: Color(0xffff0000),
                        );
                      })

                  //closed：当此对象控制的元素不可见时完成
                  // whenComplete：完成时调用的函数
                      .closed
                      .then((value) => print(value))
                      .whenComplete(() {
                    // mounted：bool值，这个State对象当前是否在结构树中
                    if (!mounted) {
                      print("已经不在结构树中了");
                    } else {
                      print("在结构树中");
                    }
                  }),
              child: Text("click"),
            );
          })
      )
      ,
    );
  }
}

/**
    const BottomSheet({
    Key key,
    this.animationController,
    this.enableDrag = true,
    this.elevation = 0.0,
    @required this.onClosing,
    @required this.builder
    })
 */
